package com.zcg.blogger.pojo;

import java.io.Serializable;
import java.util.List;

/**
 * 分页的类 
 * @author zcg
 *
 */
public class Pager implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	private static Pager pager =  new Pager();
	
	private Pager() {
		super();
	}

	private Pager(int pageSize, int pageNo) {
		super();
		this.pageSize = pageSize;
		this.pageNo = pageNo;
	}

	/**
	 * 默认的每页记录数
	 */
	private static final int DEFAULT_PAGE_SIZE = 10;

	/**
	 * 每页的记录数
	 */
	private int pageSize = DEFAULT_PAGE_SIZE;
	
	/**
	 * 当前页
	 */
	private int pageNo = 1;
	
	/**
	 * 页偏移
	 */
	private int pageOffset;
	
	/**
	 * 总行数
	 */
	private int rowCount;
	
	/**
	 * 总页数
	 */
	private int pageCount;
	
	/**
	 * 每页的记录
	 */
	private List resultList;

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageOffset() {
		return pageOffset;
	}

	public void setPageOffset(int pageOffset) {
		this.pageOffset = pageOffset;
	}

	public int getRowCount() {
		return rowCount;
	}

	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
		if(rowCount % pageSize == 0){
			this.pageCount = rowCount / pageSize;
		}else{
			this.pageCount = rowCount / pageSize + 1;
		}
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public List getResultList() {
		return resultList;
	}

	public void setResultList(List resultList) {
		this.resultList = resultList;
	}

	public static Pager getPager() {
		return pager;
	}

	@Override
	public String toString() {
		return "Pager [pageSize=" + pageSize + ", pageNo=" + pageNo
				+ ", pageOffset=" + pageOffset + ", rowCount=" + rowCount
				+ ", pageCount=" + pageCount + ", resultList=" + resultList
				+ "]";
	}
}
